<?php if(!defined('WDK_PATH')) exit('No direct script access allowed');
/**
 * @since 2011. 9. 30
 * @author kinuz
 */
class Hp_Session implements ArrayAccess
{
	protected
		/******************************************************/
		//	
		/******************************************************/
		$is_login		= false,
		$is_admin		= false,
		$session_id		= '',
		$user_seq		= 0,
		$user_login_id	= '',
		$user_name		= '';
	
	//--------------------------------------------------------------------------------------------//
	//	functions to implemet for ArrayAccess
	//--------------------------------------------------------------------------------------------//
	public final function offsetSet($offset, $value) {$this->{$offset} = $value;}
	public final function offsetExists($offset) {return isset($this->{$offset});}
	public final function offsetUnset($offset) {unset($this->{$offset});}
	public final function offsetGet($offset) {return isset($this->{$offset}) ? $this->{$offset} : null;}
	//--------------------------------------------------------------------------------------------//
	/**
	 * 	생성자
	 * @since 2011. 9. 30
	 * @author kinuz
	 */
	function __construct()
	{
		session_start();
		$this->session_id = session_id();
		foreach($_SESSION as $k=>$v)
		{
			$this->{$k} = $v;
		}
		if($this->is_admin || $this->user_seq > 0)
		{
			$this->is_login = true;
		}
	}
	
	public function set($name='', $value='')
	{
		if($value === '')
		{
			unset($_SESSION[$name]);
		}
		else
		{
			$_SESSION[$name] = $value;
		}
	}
	
	public function destroy()
	{
		session_destroy();
	}
	
	public function isLogin()
	{
		return $this->is_login;
	}
	
	public function isAdmin()
	{
		return $this->is_admin;
	}
}